<template>
    <view class="search-content">
        <view class="search-c">
            <view class="search">
              <fui-icon name="search"></fui-icon>
              <input v-model="code" placeholder="请输入口令" />
              <view @click="toUser" class="search-text">
                  搜索
              </view>
            </view>
        </view>
      <view class="search-tip">小提示：口令可以在作者页面或者视频评论区查看</view>
    </view>
  </template>
  <script setup lang="ts">
  import dyUserPlayingService from "@/api/dyUserPlayingService";
import playingStore from '@/store/playing';
  const code = ref()
  const playing = playingStore()
  const toUser = async ()=>{
  //   uni.navigateTo({
  //       url:'/pages/user/user'    
  // })
    if(!code.value){
      uni.showToast({
        title: '请输入正确的口令',
        duration: 2000,
        icon:"none"
      });
      return
    }
    try{
      const {success,result} = await dyUserPlayingService.getUserPlayingByCode({code:code.value})
      playing.playingList = result
      if(success){
          uni.navigateTo({
            url:`/pages/user/user?code=${code.value}`
          })
      }
    }catch(e:any){
      uni.showToast({
        title: e.message,
        duration: 2000,
        icon:"none"
      });
    }
    
  }
  </script>
  <style>
  .search-content{
    position: absolute;
    top: 28%;
    width: 100%;
  }
  .search-tip{
    text-align: center;
    font-size: 28rpx;
    color: white;
  }
  .search-c{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
  }
  .search{
    margin: 40rpx;
    height: 120rpx;
    border: 1rpx solid black;
    border-radius: 30rpx;
    background: white;
    display: flex;
    align-items: center;
    padding: 0 20rpx;
  }
  .search-text{
    width: 200rpx;
    background: #1371c9;
    height: 70%;
    border-radius: 20rpx;
    color: white;
    text-align: center;
    line-height: 80rpx;
  }
  input{
    margin: 0 20rpx;
    height: 80rpx;
  }
  </style>